1 Public Class FrmDEFFECTIVE_RETURN_ADD
2     Dim return_ID As Integer
3     Dim _Match As Boolean
4     Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
5         Me.Close()
6     End Sub
7
8     Private Sub FrmDEFFECTIVE_RETURN_ADD_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
9         Me.Text =
"Defective Return Stocks"
10     End Sub
11
12     Private Sub FrmDEFFECTIVE_RETURN_ADD_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
13         lstitems.Items.Clear()
14         If Split(Me.Text,
" - ")(1) = "Add" Then
15             
'FrmDEFFECTIVE_RETURN_STOCKS_DATA_ADD.ShowDialog()
16             FrmDEFFECTIVE_RETURN_PENDING.ShowDialog()
17         Else
18             txtpo.Text = globalID
19             sqlSTR =
"SELECT *, *, *, * " & _
20                      
"FROM TBL_Deffective_PO_Details " & _
21                      
"INNER JOIN TBL_Deffective_PO_Return ON TBL_Deffective_PO_Details.DEF_PO_ID = TBL_Deffective_PO_Return.DEF_PO_ID " & _
22                      
"INNER JOIN TBL_Deffective_PO_Return_Details ON TBL_Deffective_PO_Return.Return_ID = TBL_Deffective_PO_Return_Details.Return_ID " & _
23                      
" AND TBL_Deffective_PO_Return_Details.Item_ID = TBL_Deffective_PO_Details.Item_ID " & _
24                      
"INNER JOIN TBL_Category_Item_File ON TBL_Deffective_PO_Return_Details.Item_ID = TBL_Category_Item_File.Item_ID " & _
25                      
"INNER JOIN TBL_Purchase_Order ON TBL_Deffective_PO_Return.Purchase_ID = TBL_Purchase_Order.Purchase_ID " & _
26                      
"INNER JOIN TBL_Purchase_Detail ON TBL_Purchase_Order.Purchase_Id = TBL_Purchase_Detail.Purchase_ID " & _
27                      
" AND TBL_Purchase_Detail.Item_ID = TBL_Deffective_PO_Return_Details.Item_ID " & _
28                      
"INNER JOIN TBL_Suppliers ON TBL_Purchase_Order.Supp_ID = TBL_Suppliers.Supp_ID " & _
29                      
"WHERE TBL_Deffective_PO_Details.DEF_PO_ID =" & txtpo.Text
30             
'fix bugs 'z123
31             
'MsgBox(txtpo.Text)
32             ExecuteSQLQuery(sqlSTR)
33             If sqlDT.Rows.Count >
0 Then
34                 return_ID = sqlDT.Rows(
0)("Return_ID")
35                 txtSuppname.Text = R_Change(sqlDT.Rows(
0)("suppname"))
36                 txtadd.Text = R_Change(sqlDT.Rows(
0)("address"))
37                 txtdeliver.Text = R_Change(sqlDT.Rows(
0)("delivery_term"))
38                 txtreturn.Text = sqlDT.Rows(
0)("Return_Date")
39             End If
40
41             For i =
0 To sqlDT.Rows.Count - 1
42                 With lstitems
43                     .Items.Add(sqlDT.Rows(i)(
"Item_ID"))
44                     .Items((.Items.Count -
1)).SubItems.Add(sqlDT.Rows(i)("Purchase_Detail_ID"))
45                     .Items((.Items.Count -
1)).SubItems.Add(R_Change(sqlDT.Rows(i)("Item_Name")))
46                     .Items((.Items.Count -
1)).SubItems.Add(sqlDT.Rows(i)("Item_QTY"))
47                     .Items((.Items.Count -
1)).SubItems.Add(sqlDT.Rows(i)("Item_Price"))
48                     .Items((.Items.Count -
1)).SubItems.Add(sqlDT.Rows(i)("Def_QTY") - sqlDT.Rows(i)("Return_QTY"))
49                     .Items((.Items.Count -
1)).SubItems.Add(sqlDT.Rows(i)("Return_QTY"))
50                     .Items((.Items.Count -
1)).SubItems.Add(sqlDT.Rows(i)("Unit"))
51                 End With
52             Next
53             cmdSave.Enabled = False
54         End If
55     End Sub
56
57     Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
58         Dim i As Integer
59         Dim total_price As Double
60         Dim return_QTY As Integer, Item_QTY As Integer
61         Dim return_IDx As Integer
62         Item_QTY =
0 'no use
63         total_price =
0 'no use
64         If Split(Me.Text,
" - ")(1) = "Add" Then
65
66             If lstitems.Items.Count =
0 Then
67                 MsgBox(
"No item details, please add details !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
68                 Exit Sub
69             End If
70             sqlSTR =
"INSERT INTO TBL_Deffective_PO_Return (DEF_PO_ID, Purchase_ID, SupplierName, Delivery_term, Address, Return_Date, Fully_Return) " & _
71                            
"VALUES (" & txtpo.Text & ", " _
72                                       & txtpo2.Text &
", " _
73                                   & 
"'" & R_eplace(txtSuppname.Text) & "', " _
74                                   & 
"'" & txtdeliver.Text & "', " _
75                                   & 
"'" & R_eplace(txtadd.Text) & "', " _
76                                   & 
"'" & txtreturn.Text & "', " _
77                                   & 
"'Yes'" & ")"
78             
'MsgBox(sqlSTR)
79             ExecuteSQLQuery(sqlSTR)
80             
'MsgBox(sqlSTR)
81             sqlSTR =
"SELECT * FROM TBL_Deffective_PO_Return ORDER BY Return_ID DESC"
82             ExecuteSQLQuery(sqlSTR)
83             If sqlDT.Rows.Count >
0 Then
84                 return_IDx = sqlDT.Rows(
0)("Return_ID")
85             End If
86             For i =
0 To lstitems.Items.Count - 1
87                 sqlSTR =
"INSERT INTO TBL_Deffective_PO_Return_Details (Purchase_ID, Return_ID, Purchase_Detail_ID, Item_ID, Return_Qty, Unit) " & _
88                          
"VALUES (" & txtpo2.Text & ", " _
89                                     & return_IDx &
", " _
90                                     & lstitems.Items(i).SubItems(
1).Text & ", " _
91                                     & lstitems.Items(i).Text &
", " _
92                                     & lstitems.Items(i).SubItems(
6).Text & ", " _
93                                     & 
"'" & lstitems.Items(i).SubItems(7).Text & "')"
94                 ExecuteSQLQuery(sqlSTR)
95
96                 
''UPDATE DEFECTIVE QTY
97
98                 
'sqlSTR = "UPDATE TBL_Deffective_PO_Details SET def_QTY = def_QTY - " & lstitems.Items(i).SubItems(6).Text & _
99                 
' "WHERE Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text & _
100                 
' " AND DEF_PO_ID =" & txtpo.Text
101                 
'ExecuteSQLQuery(sqlSTR)
102
103                 
''UPDATE PURCHASE QTY
104                 
'total_price = CDbl((CDbl(lstitems.Items(i).SubItems(3).Text) + CDbl(lstitems.Items(i).SubItems(6).Text))) * CDbl(lstitems.Items(i).SubItems(4).Text)
105                 
'sqlSTR = "UPDATE TBL_Purchase_Detail SET Item_QTY =" & "Item_QTY + " & lstitems.Items(i).SubItems(6).Text & ", " _
106                 
' & "Total_Price = " & total_price _
107                 
' & " WHERE Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
108                 
'ExecuteSQLQuery(sqlSTR)
109
110                 
'UPDATE STOCKS
111                 sqlSTR =
"UPDATE TBL_Stocks_Balances SET Item_QTY =" & "Item_QTY + " & lstitems.Items(i).SubItems(6).Text & _
112                          
" WHERE Item_ID =" & lstitems.Items(i).Text
113                 ExecuteSQLQuery(sqlSTR)
114
115                 
'find if it's a pending item
116                 
'----
117                 
'sqlSTR = "SELECT * FROM TBL_Deffective_PO_Details " & _
118                 
' "WHERE Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text & _
119                 
' " AND DEF_PO_ID =" & txtpo.Text
120
121                 
'ExecuteSQLQuery(sqlSTR)
122                 
'If sqlDT.Rows.Count > 0 Then
123                 
' If sqlDT.Rows(0)("Pending_ID") > 0 Then
124                 
' sqlSTR = "UPDATE TBL_Pending_Item SET Returnx = 'Yes' " & ", " _
125                 
' & "Return_Date ='" & txtreturn.Text & _
126                 ' "' WHERE Pending_ID =" & sqlDT.Rows(
0)("Pending_ID")
127                 
' ExecuteSQLQuery(sqlSTR)
128
129                 
' sqlSTR = "UPDATE TBL_Stocks_Balances SET Item_QTY =" & "Item_QTY + " & lstitems.Items(i).SubItems(6).Text & _
130                 
' " WHERE Item_ID =" & lstitems.Items(i).Text
131                 
' ExecuteSQLQuery(sqlSTR)
132                 
'End If
133                 
'Else
134                 
' sqlSTR = "UPDATE TBL_Stocks_Balances SET Item_QTY =" & "Item_QTY + " & lstitems.Items(i).SubItems(6).Text & _
135                 
' " WHERE Item_ID =" & lstitems.Items(i).Text
136                 
' ExecuteSQLQuery(sqlSTR)
137                 
'End If
138             Next
139
140
141
142             
'CHECK IF IT IS FULLY RETURNED
143             
'
144             sqlSTR =
"SELECT *, *, *, * " & _
145                      
"FROM TBL_Deffective_PO " & _
146                      
"INNER JOIN TBL_Deffective_PO_Return ON TBL_Deffective_PO.Def_PO_ID = TBL_Deffective_PO_Return.Def_PO_ID " & _
147                      
"INNER JOIN TBL_Deffective_PO_Details ON TBL_Deffective_PO_Return.Def_PO_ID = TBL_Deffective_PO_Details.Def_PO_ID " & _
148                      
"LEFT OUTER JOIN TBL_Deffective_PO_Return_Details ON TBL_Deffective_PO_Return.Return_ID = TBL_Deffective_PO_Return_Details.Return_ID " & _
149                      
" AND TBL_Deffective_PO_Details.Item_ID = TBL_Deffective_PO_Return_Details.Item_ID " & _
150                      
"WHERE TBL_Deffective_PO.Def_PO_ID =" & txtpo.Text & _
151                      
" ORDER BY TBL_Deffective_PO_Details.Item_ID ASC"
152             ExecuteSQLQuery(sqlSTR)
153             
' MsgBox(sqlDT.Rows(0)("Def_ID") & " -- " & sqlDT.Rows(0)("Return_ID"))
154             If sqlDT.Rows.Count >
0 Then
155                 For x =
0 To sqlDT.Rows.Count - 1
156                     If sqlDT.Rows(x)(
"Return_QTY").ToString <> "" Then
157                         _Match = True
158                         If CDbl(sqlDT.Rows(x)(
"Def_QTY")) <> CDbl(sqlDT.Rows(x)("Return_QTY")) Then
159                             _Match = False
160                             Exit For
161                         Else
162                             _Match = True
163                         End If
164                     Else
165                         _Match = False
166                         Exit For
167                     End If
168                 Next
169                 If Not _Match Then
170                     sqlSTR =
"UPDATE TBL_Deffective_PO_Return SET Fully_Return = 'No' WHERE DEF_PO_ID =" & txtpo.Text
171                     ExecuteSQLQuery(sqlSTR)
172                 End If
173             End If
174             Audit_Trail(xUser_ID, TimeOfDay,
"Add New Return Stocks")
175         Else
176             
'EDIT
177             For i =
0 To lstitems.Items.Count - 1
178                 sqlSTR =
"SELECT * FROM TBL_Deffective_PO_Return_Details WHERE Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
179                 ExecuteSQLQuery(sqlSTR)
180                 If sqlDT.Rows.Count >
0 Then
181                     
'-comment
182                     return_QTY = sqlDT.Rows(
0)("Return_QTY")
183                     If CDbl(lstitems.Items(i).SubItems(
5).Text) > 0 Then
184                         sqlSTR =
"SELECT * FROM " & _
185                                  
"TBL_Deffective_PO_Return_Details WHERE Return_ID =" & return_ID & _
186                                  
" AND Item_ID =" & lstitems.Items(i).Text
187                         ExecuteSQLQuery(sqlSTR)
188                         If sqlDT.Rows.Count >
0 Then
189                             sqlSTR =
"UPDATE TBL_Deffective_PO_Return_Details " & _
190                                      
"SET Return_QTY = Return_QTY + " & lstitems.Items(i).SubItems(6).Text & _
191                                      
" WHERE Return_ID =" & return_ID & _
192                                      
" AND Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
193                             ExecuteSQLQuery(sqlSTR)
194                         Else
195                             
'ADD NEW DATA IF NOT FIND
196                             sqlSTR =
"INSERT INTO TBL_Deffective_PO_Return_Details (Purchase_ID, Return_ID, Purchase_Detail_ID, Item_ID, Return_Qty, Unit) " & _
197                                      
"VALUES (" & txtpo2.Text & ", " _
198                                                 & return_ID &
", " _
199                                                 & lstitems.Items(i).SubItems(
1).Text & ", " _
200                                                 & lstitems.Items(i).Text &
", " _
201                                                 & lstitems.Items(i).SubItems(
6).Text & ", " _
202                                                 & 
"'" & lstitems.Items(i).SubItems(7).Text & "')"
203                             ExecuteSQLQuery(sqlSTR)
204                         End If
205  
206                     End If
207
208                     
'end
209
210                     
'If sqlDT.Rows(0)("Return_QTY") > lstitems.Items(i).SubItems(6).Text Then
211                     
'add 3 > 2
212
213                     
'UPDATE DEFECTIVE PO DETAILS
214                     
'sqlSTR = "UPDATE TBL_Deffective_PO_Details " & _
215                     
' "SET def_QTY = def_QTY - " & CDbl(lstitems.Items(i).SubItems(6).Text) & _
216                     
' " WHERE TBL_Deffective_PO_Details.DEF_PO_ID =" & txtpo.Text
217                     
''"AND TBL_Deffective_PO_Details.Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
218                     
''"SET def_QTY = def_QTY + " & (return_QTY - lstitems.Items(i).SubItems(6).Text) & _
219
220                     
''--UNCOMMENT
221                     
'ExecuteSQLQuery(sqlSTR)
222                     
'sqlSTR = "UPDATE TBL_Deffective_PO_Return_Details " & _
223                     
' "SET Return_QTY = Return_QTY + " & lstitems.Items(i).SubItems(6).Text & _
224                     
' " WHERE Return_ID =" & return_ID & _
225                     
' " AND Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
226                     
'ExecuteSQLQuery(sqlSTR)
227                     
''--END
228
229                     
'------can be uncomment
230                     
'UPDATE PURCHASE DETAIL
231                     
' total_price = (CDbl(lstitems.Items(i).SubItems(3).Text) + (CDbl(lstitems.Items(i).SubItems(5).Text) - CDbl(lstitems.Items(i).SubItems(6).Text))) * CDbl(lstitems.Items(i).SubItems(4).Text)
232                     
' sqlSTR = "SELECT * FROM TBL_Purchase_Detail WHERE Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
233                     
' ExecuteSQLQuery(sqlSTR)
234                     
' Item_QTY = sqlDT.Rows(0)("Item_QTY")
235
236                     
''MsgBox((sqlDT.Rows(0)("Item_QTY") - (CDbl(lstitems.Items(i).SubItems(5).Text) + return_QTY)) + CDbl(lstitems.Items(i).SubItems(6).Text))
237                     
'sqlSTR = "UPDATE TBL_Purchase_Detail " & _
238                     
' "SET Item_QTY = Item_QTY + " & CDbl(lstitems.Items(i).SubItems(6).Text) & ", " _
239                     
' & "Total_Price=" & total_price & _
240                     
' " WHERE Purchase_ID =" & txtpo.Text & _
241                     
' " AND Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
242                     
''"SET Item_QTY = " & (sqlDT.Rows(0)("Item_QTY") - return_QTY) + CDbl(lstitems.Items(i).SubItems(6).Text) & ", " _
243                     
'ExecuteSQLQuery(sqlSTR)
244                     
'-----------
245
246                     
''--UNCOMMENT
247                     
''update balances
248                     
'sqlSTR = "UPDATE TBL_Stocks_Balances " & _
249                     
' "SET Item_QTY = Item_QTY + " & CDbl(lstitems.Items(i).SubItems(6).Text) & _
250                     
' "WHERE Item_ID =" & lstitems.Items(i).Text
251                     
''"SET Item_QTY = " & (Item_QTY - return_QTY) + CDbl(lstitems.Items(i).SubItems(6).Text) & _
252                     
'ExecuteSQLQuery(sqlSTR)
253                     
'---END
254                     
'ElseIf sqlDT.Rows(0)("Return_QTY") < lstitems.Items(i).SubItems(6).Text Then
255
256                     
'DEDUCT--
257                     
'UPDATE DEFECTIVE PO DETAILS
258                     
'sqlSTR = "UPDATE TBL_Deffective_PO_Details " & _
259                     
' "SET def_QTY = def_QTY - " & CDbl(lstitems.Items(i).SubItems(6).Text) & _
260                     
' " WHERE TBL_Deffective_PO_Details.DEF_PO_ID =" & txtpo.Text
261                     
'' " AND TBL_Deffective_PO_Details.Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
262                     
''"SET def_QTY = def_QTY - " & (CDbl(lstitems.Items(i).SubItems(6).Text) - return_QTY) & _
263                     
'ExecuteSQLQuery(sqlSTR)
264
265                     
'-uncomment
266                     
'sqlSTR = "UPDATE TBL_Deffective_PO_Return_Details " & _
267                     
' "SET Return_QTY = Return_QTY - " & lstitems.Items(i).SubItems(6).Text & _
268                     
' " WHERE Return_ID =" & return_ID & _
269                     
' " AND Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
270                     
'ExecuteSQLQuery(sqlSTR)
271                     
''--END
272                     
'UPDATE DETAILS
273                     
' sqlSTR = "SELECT * FROM TBL_Purchase_Detail WHERE Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
274                     
' ExecuteSQLQuery(sqlSTR)
275                     
' Item_QTY = sqlDT.Rows(0)("Item_QTY")
276
277                     
' total_price = CDbl(CDbl(sqlDT.Rows(0)("Item_QTY") - return_QTY) + CDbl(lstitems.Items(i).SubItems(6).Text)) * lstitems.Items(i).SubItems(4).Text
278
279                     
' sqlSTR = "UPDATE TBL_Purchase_Detail " & _
280                     
' "SET Item_QTY = Item_QTY + " & lstitems.Items(i).SubItems(6).Text & ", " _
281                     
' & "Total_Price=" & total_price & _
282                     
' " WHERE Purchase_ID =" & txtpo.Text & _
283                     
' " AND Purchase_Detail_ID =" & lstitems.Items(i).SubItems(1).Text
284                     
''"SET Item_QTY = " & (sqlDT.Rows(0)("Item_QTY") - return_QTY) + CDbl(lstitems.Items(i).SubItems(6).Text) & ", " _
285
286                     
'ExecuteSQLQuery(sqlSTR)
287
288
289                     
''--- uncomennt
290                     
'UPDATE STOCK BALANCES
291                     sqlSTR =
"UPDATE TBL_Stocks_Balances " & _
292                              
"SET Item_QTY = Item_QTY + " & CDbl(lstitems.Items(i).SubItems(6).Text) & _
293                              
"WHERE Item_ID =" & lstitems.Items(i).Text
294                     
' ' "SET Item_QTY = " & (Item_QTY - return_QTY) + CDbl(lstitems.Items(i).SubItems(6).Text) & _
295                     ExecuteSQLQuery(sqlSTR)
296                     
'Else
297                     
'MsgBox("RETURN")
298                     
'MsgBox(lstitems.FocusedItem.Text)
299                     
'End If
300                 Else
301                     
'MsgBox("RETURN HERE")
302                 End If
303             Next
304
305             
'CHECK IF IT IS FULLY RETURNED
306             sqlSTR =
"SELECT *, *, *, * " & _
307                      
"FROM TBL_Deffective_PO " & _
308                      
"INNER JOIN TBL_Deffective_PO_Return ON TBL_Deffective_PO.Def_PO_ID = TBL_Deffective_PO_Return.Def_PO_ID " & _
309                      
"INNER JOIN TBL_Deffective_PO_Details ON TBL_Deffective_PO_Return.Def_PO_ID = TBL_Deffective_PO_Details.Def_PO_ID " & _
310                      
"LEFT OUTER JOIN TBL_Deffective_PO_Return_Details ON TBL_Deffective_PO_Return.Return_ID = TBL_Deffective_PO_Return_Details.Return_ID " & _
311                      
" AND TBL_Deffective_PO_Details.Item_ID = TBL_Deffective_PO_Return_Details.Item_ID " & _
312                      
"WHERE TBL_Deffective_PO.Def_PO_ID =" & txtpo.Text & _
313                      
" ORDER BY TBL_Deffective_PO_Details.Item_ID ASC"
314             ExecuteSQLQuery(sqlSTR)
315             If sqlDT.Rows.Count >
0 Then
316                 For x =
0 To sqlDT.Rows.Count - 1
317                     If sqlDT.Rows(x)(
"Return_QTY").ToString <> "" Then
318                         _Match = True
319                         If CDbl(sqlDT.Rows(x)(
"Def_QTY")) <> CDbl(sqlDT.Rows(x)("Return_QTY")) Then
320                             _Match = False
321                             Exit For
322                         Else
323                             _Match = True
324                         End If
325                     Else
326                         _Match = False
327                         Exit For
328                     End If
329                 Next
330                 If Not _Match Then
331                     sqlSTR =
"UPDATE TBL_Deffective_PO_Return SET Fully_Return ='No' WHERE DEF_PO_ID =" & txtpo.Text
332                     ExecuteSQLQuery(sqlSTR)
333                 Else
334                     sqlSTR =
"UPDATE TBL_Deffective_PO_Return SET Fully_Return ='Yes' WHERE DEF_PO_ID =" & txtpo.Text
335                     ExecuteSQLQuery(sqlSTR)
336                 End If
337                 With FrmDEFFECTIVE_RETURN_STOCKS
338                     sqlSTR =
"SELECT DEF_PO_ID AS 'Defective ID', Purchase_ID as 'Purchase No', Replace(Replace(SupplierName,'$.$',''''),'$..$',',') as 'Supplier Name', Replace(Replace(Delivery_Term,'$.$',''''),'$..$',',') as 'Delivery Term', Replace(Replace(Address,'$.$',''''),'$..$',',') AS 'Address', Fully_Return AS 'Return' FROM TBL_Deffective_PO_Return " & _
339                              
"WHERE Return_Date ='" & Format(.dtreturn.Value, "MM/dd/yyyy") & "' ORDER BY DEF_PO_ID ASC"
340                     FillListView(ExecuteSQLQuery(sqlSTR), .lstdeffect,
0)
341                     For i =
0 To .lstdeffect.Items.Count - 1
342                         
'MsgBox(.lstdeffect.Items(i).SubItems(5).Text)
343                         If .lstdeffect.Items(i).SubItems(
5).Text = "Yes" Then
344                             .lstdeffect.Items(i).ForeColor = Color.Brown
345                         Else
346                             .lstdeffect.Items(i).ForeColor = Color.Black
347                         End If
348                     Next
349                 End With
350
351             End If
352             Audit_Trail(xUser_ID, TimeOfDay,
"Edit Return Stocks")
353         End If
354         MsgBox(
"Record successfuly updated !!", MsgBoxStyle.Information, "Sales and Inventory")
355         Me.Close()
356     End Sub
357
358     Private Sub txtpo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtpo.Click
359         If Split(Me.Text,
" - ")(1) = "Edit" Then Exit Sub
360         FrmDEFFECTIVE_RETURN_PENDING.ShowDialog()
361     End Sub
362
363     Private Sub txtpo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtpo.TextChanged
364         If Split(Me.Text,
" - ")(1) = "Edit" Then Exit Sub
365         If txtpo.Text =
"" Then Exit Sub
366         
'MsgBox(txtpo.Text & " " & txtpo2.Text)
367         
'sqlSTR = "SELECT *, *, *, * " & _
368         
' "FROM (((TBL_Suppliers " & _
369         
' "INNER JOIN TBL_Purchase_Order ON TBL_Suppliers.Supp_ID = TBL_Purchase_Order.Supp_ID) " & _
370         
' "INNER JOIN TBL_Purchase_Detail ON TBL_Purchase_Order.Purchase_ID = TBL_Purchase_Detail.Purchase_ID) " & _
371         
' "INNER JOIN TBL_Category_Item_File ON TBL_Purchase_Detail.Item_ID = TBL_Category_Item_File.Item_ID) " & _
372         
' "WHERE TBL_Purchase_Order.Purchase_ID =" & txtpo.Text
373
374         
'---
375         sqlSTR =
"SELECT *, *, *, *, * " & _
376                  
"FROM ((((TBL_Suppliers " & _
377                  
"INNER JOIN TBL_Purchase_Order ON TBL_Suppliers.Supp_ID = TBL_Purchase_Order.Supp_ID) " & _
378                  
"INNER JOIN TBL_Purchase_Detail ON TBL_Purchase_Order.Purchase_ID = TBL_Purchase_Detail.Purchase_ID) " & _
379                  
"INNER JOIN TBL_Deffective_PO ON TBL_Purchase_Order.Purchase_ID = TBL_Deffective_PO.Purchase_ID) " & _
380                  
"INNER JOIN TBL_Category_Item_File ON TBL_Purchase_Detail.Item_ID = TBL_Category_Item_File.Item_ID) " & _
381                  
"WHERE TBL_Deffective_PO.DEF_PO_ID =" & txtpo.Text
382         
'---
383         
' MsgBox(txtpo.Text & " " & txtpo2.Text)
384         
'MsgBox(sqlSTR)
385         ExecuteSQLQuery(sqlSTR)
386         
'MsgBox(sqlDT.Rows.Count)
387         If sqlDT.Rows.Count >
0 Then
388             txtSuppname.Text = R_Change(sqlDT.Rows(
0)("suppname"))
389             txtadd.Text = R_Change(sqlDT.Rows(
0)("address"))
390             txtdeliver.Text = R_Change(sqlDT.Rows(
0)("delivery_term"))
391         Else
392             sqlSTR =
"SELECT *, *, *, * " & _
393                      
"FROM (((TBL_Suppliers " & _
394                      
"INNER JOIN TBL_Purchase_Order ON TBL_Suppliers.Supp_ID = TBL_Purchase_Order.Supp_ID) " & _
395                      
"INNER JOIN TBL_Purchase_Detail ON TBL_Purchase_Order.Purchase_ID = TBL_Purchase_Detail.Purchase_ID) " & _
396                      
"INNER JOIN TBL_Category_Item_File ON TBL_Purchase_Detail.Item_ID = TBL_Category_Item_File.Item_ID) " & _
397                      
"WHERE TBL_Purchase_Order.Purchase_ID =" & txtpo2.Text
398             ExecuteSQLQuery(sqlSTR)
399             If sqlDT.Rows.Count >
0 Then
400                 txtSuppname.Text = R_Change(sqlDT.Rows(
0)("suppname"))
401                 txtadd.Text = R_Change(sqlDT.Rows(
0)("address"))
402                 txtdeliver.Text = R_Change(sqlDT.Rows(
0)("delivery_term"))
403             End If
404         End If
405
406     End Sub
407
408     Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
409         If txtpo.Text =
"" Then Exit Sub
410         FormShow(FrmDEFFECTIVE_RETURN_STOCKS_DATA_ADD, False,
0, 0)
411         
'FrmDEFFECTIVE_RETURN_STOCK_LIST.ShowDialog()
412     End Sub
413
414     Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
415         If lstitems.Items.Count =
0 Then Exit Sub
416         lstitems.Focus()
417         If lstitems.FocusedItem.SubItems(
5).Text = 0 Then
418             MsgBox(
"This item has already been return, modifying the data is not allowed !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
419             Exit Sub
420         End If
421         With FrmDEFFECTIVE_RETURN_STOCKS_DATA_ADD
422             .txtid.Text = Me.lstitems.FocusedItem.Text
423             .txtdtl.Text = Me.lstitems.FocusedItem.SubItems(
1).Text
424             .txtname.Text = Me.lstitems.FocusedItem.SubItems(
2).Text
425             .txtdesc.Text = Me.lstitems.FocusedItem.SubItems(
3).Text
426             .txtprice.Text = Me.lstitems.FocusedItem.SubItems(
4).Text
427             .Label11.Text = Me.lstitems.FocusedItem.SubItems(
6).Text
428             
'.txtbarcode.Text = Me.lstitems.FocusedItem.SubItems(5).Text
429             .txtreturnqty.Text = Me.lstitems.FocusedItem.SubItems(
6).Text
430             .txtdefqty.Text = Me.lstitems.FocusedItem.SubItems(
5).Text
431             .txtunit.Text = Me.lstitems.FocusedItem.SubItems(
7).Text
432         End With
433         FormShow(FrmDEFFECTIVE_RETURN_STOCKS_DATA_ADD, True, lstitems.FocusedItem.SubItems(
1).Text, txtpo.Text)
434     End Sub
435 End Class


Gõ tìm kiếm nhanh...